﻿using A.M.ETO;
using L.M.System.Application.IServices;
using L.M.System.Application.Services;
using L.M.System.Domain.DTO;
using L.M.System.Domain.Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace L.M.System.Read.API.Controllers
{
    /// <summary>
    /// 工作周
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Working_hoursController : ControllerBase
    {
        private readonly IWorking_hoursServices working_Hours;
        public Working_hoursController(IWorking_hoursServices working_Hours)
        {
            this.working_Hours = working_Hours;
        }

        /// <summary>
        /// 工作时间查询
        /// </summary>
        /// <returns>工作时间查询</returns>
        [HttpGet]
        public async Task<IActionResult> GetWorkingShowInfpr()
        {
            ApiReturn<working_hours> apiReturn = new ApiReturn<working_hours>();
            var list = (await working_Hours.GetShowQueryableAsync()).OrderBy(c=>c.whid).ToList();
            

            apiReturn.Code = 200;
            apiReturn.Message = "成功";
            apiReturn.ListInfor = list;
            return Ok(apiReturn);

        }

        /// <summary>
        /// 修改工作时间
        /// </summary>
        /// <param name="works">工作日</param>
        /// <returns>修改工作时间</returns>
        [HttpPost]
        public async Task<IActionResult> AddWorkInfor(WorkInforDTO works)
        {
            var res = await working_Hours.AddWorkInfor(works);
            return Ok(res);
        }

        /// <summary>
        /// 获取所有的工作时间
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> GetShowInforAsyncWork()
        {
            var list =await working_Hours.GetShowInforAsync();
            return Ok(list);
        }
    }
}
